#include "ScrollArea.h"
#include <iostream>

void ScrollArea:: handle_value_change(int value)
{
	line_edit->setText(QString::number(value));
	return ;
}

ScrollArea::ScrollArea(QString& str)
{
	QGridLayout *layout = new QGridLayout(this);
	if (!layout) {
		std::cout << "malloc layout failed" <<std::endl;
		return ;
	}
	label = new QLabel(str);
	if (!label) {
		std::cout << "malloc label failed" <<std::endl;
		return ;
	}
	
	line_edit = new QLineEdit();
	if (!line_edit) {
		std::cout << "malloc line_edit failed" <<std::endl;
		return ;
	}
	
	slider = new QSlider();
	if (!slider) {
		std::cout << "malloc slider failed" <<std::endl;
		return ;
	}
	
	layout->addWidget(label, 0, 0, 1, 1, Qt::AlignHCenter);
	layout->addWidget(line_edit, 1, 0, 1, 1, Qt::AlignHCenter);
	layout->addWidget(slider, 2, 0, 1, 1, Qt::AlignHCenter);	

	connect(slider, SIGNAL(valueChanged(int)), this, SLOT(handle_value_change(int)));
}

QSlider *ScrollArea::getSlider()
{
	return slider;
}
#if 0
ScrollArea::ScrollArea(QWidget* parent, QString str)
{
	this->setParent(parent);
	ScrollArea(str);
}
#endif

